<?php 
class MailerComponent extends Object {
	public $components 	= array('Email');
	public $name 		= 'Mailer';
	/**
	 * @var EmailComponent
	 */
	public $Email;
	
	public function startup() {
		if (Configure::read('debug') == 2) {
			$this->Email->delivery = 'debug';
		}
		$this->Email->sendAs 	= Configure::read('Email.sendAs');
	}
	
	public function sendRegistrationEmail($to) {
		$this->Email->to 		= $to;
		$this->Email->subject 	= 'Registration confirmation';
		$this->Email->from 		= Configure::read('Email.fromName').' <'.Configure::read('Email.fromAddress').'>';
		$this->Email->replyTo	= Configure::read('Email.replyAddress');
		$this->Email->template 	= 'register';

		return $this->Email->send();
	}
	
	public function sendChangeEmail($to) {
		$this->Email->to 		= $to;
		$this->Email->subject 	= 'Email confirmation';
		$this->Email->from 		= Configure::read('Email.fromName').' <'.Configure::read('Email.fromAddress').'>';
		$this->Email->replyTo	= Configure::read('Email.replyAddress');
		$this->Email->template 	= 'confirm_change';

		return $this->Email->send();
	}
	
	
	public function sendRecoveryEmail($to) {
		$this->Email->to 		= $to;
		$this->Email->subject 	= 'Recover your password';
		$this->Email->from 		= Configure::read('Email.fromName').' <'.Configure::read('Email.fromAddress').'>';
		$this->Email->replyTo	= Configure::read('Email.replyAddress');
		$this->Email->template 	= 'recover';

		return $this->Email->send();
	}
}